package com.base.common.net;

/**
 * Date: 2019/9/26 14:19
 * Author: Jayden
 * Description:可以接收上游发送的empty
 * Version:
 */
public abstract class NullAbleObserver<T> extends BaseObserver<T> {
    private T t;
    private boolean isError;

    @Override
    public void onNext(T t) {
        this.t = t;
        super.onNext(t);
    }

    @Override
    public void onError(Throwable e) {
        isError = true;
        super.onError(e);
    }

    @Override
    public void onComplete() {
        super.onComplete();
        if (t == null && !isError) {
            onNext(t);
        }
    }
}
